package com.liangxy.news.model;

import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;

/**
 * Entity for storing news detail content
 */
@Entity(tableName = "news_detail",
        foreignKeys = @ForeignKey(entity = News.class,
                parentColumns = "uniquekey",
                childColumns = "newsId",
                onDelete = ForeignKey.CASCADE))
public class NewsDetail {
    
    @PrimaryKey
    @NonNull
    private String newsId;
    
    private String content;
    private long timestamp;
    private String title;
    private String date;
    private String author;
    
    @Ignore
    public NewsDetail(@NonNull String newsId, String content) {
        this.newsId = newsId;
        this.content = content;
        this.timestamp = System.currentTimeMillis();
    }
    
    public NewsDetail(@NonNull String newsId, String title, String date, String author, String content) {
        this.newsId = newsId;
        this.title = title;
        this.date = date;
        this.author = author;
        this.content = content;
        this.timestamp = System.currentTimeMillis();
    }
    
    @NonNull
    public String getNewsId() {
        return newsId;
    }
    
    public void setNewsId(@NonNull String newsId) {
        this.newsId = newsId;
    }
    
    public String getContent() {
        return content;
    }
    
    public void setContent(String content) {
        this.content = content;
    }
    
    public long getTimestamp() {
        return timestamp;
    }
    
    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }
    
    public String getTitle() {
        return title;
    }
    
    public void setTitle(String title) {
        this.title = title;
    }
    
    public String getDate() {
        return date;
    }
    
    public void setDate(String date) {
        this.date = date;
    }
    
    public String getAuthor() {
        return author;
    }
    
    public void setAuthor(String author) {
        this.author = author;
    }
} 